package com.ccc.demoboot.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ccc.demoboot.common.R;
import com.ccc.demoboot.pojo.Rolemidmenu;
import com.ccc.demoboot.service.RolemidmenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author wz
 * @Date 2024/5/20 11:42
 * @PackageName:com.ccc.demoboot.controller
 * @ClassName: RolemidmenuController
 */

@RequestMapping("/RolemidmenuController")
@RestController
public class RolemidmenuController {

    @Autowired
    RolemidmenuService rolemidmenuService;


    /**
     * 查询角色对应的菜单权限
     * @param rolemidmenu
     * @return
     */
    @PostMapping("/select")
    public R select(@RequestBody Rolemidmenu rolemidmenu){
        QueryWrapper<Rolemidmenu> rolemidmenuQueryWrapper = new QueryWrapper<>();
        rolemidmenuQueryWrapper.setEntity(rolemidmenu);
        List<Rolemidmenu> list = this.rolemidmenuService.list(rolemidmenuQueryWrapper);
        return new R().add("list",list);
    }



    @PostMapping("/up")
    public R up(@RequestBody Map<String,Object> map){

        Integer roleid=(Integer) map.get("roleid");
        List list= (List) map.get("menuid");
        int a=this.rolemidmenuService.updateRole(roleid,list);
        return new R();
    }



}
